airport_noise_contours <- read_sf('Airport_Noise_Contours.shp')
airport_noise_data <- read_sf('Day_4326_II.shp')
unique(airport_noise_data$DN)
##   [1]  34  19  36  42  43  45  49  46  51  47  44  39  41  53  38  40  52  50
##  [19]  48  17  18  29  33  35  30  20  21  37  27  26  32  28  31  22  23  24
##  [37]  25  15  54  14  16  55  56  57  61  63  59  58  65  60  66  64  62  67
##  [55]  70  71  69  72  73  74  75  76  77  78  79  82  84  80  81  88  86  85
##  [73]  89  87  83  90  68  91  92  93  94  95  96  97  98  -8  -6  12  10  11
##  [91]   8  13   9   0   1   4  -5   3   5   6  -3  -2  -1  -7 -14   2   7  -4
## [109] -17 -12 -13 -80  -9 -11 -10 -16 -19 -15 -18 -22  99
unique(airport_noise_data$layer)
## [1] "1_4" "2_4" "3_4" "4_4" "5_4"
airport_noise_data %>%
  as_tibble() %>%
  group_by(layer) %>%
  summarise(n = n(),
            avg_dn = mean(DN))
## # A tibble: 5 × 3
##   layer       n avg_dn
##   <chr>   <int>  <dbl>
## 1 1_4   1973248   60.0
## 2 2_4   1590456   60.0
## 3 3_4   1555810   59.0
## 4 4_4    962644   57.3
## 5 5_4    483730   58.1
length(unique(airport_noise_data$geometry))
## [1] 6563975
# Visualize
pal <- colorNumeric(palette = colorRampPalette(colors = c("yellow", "red"), space = "Lab"), domain = NULL)

airport_noise_viz <- leaflet() %>% 
      addProviderTiles(providers$MtbMap) %>%
              addProviderTiles(providers$Stadia.StamenTerrainBackground,
                               options = providerTileOptions(opacity = 0.9, api_key = "2960e34d-9997-48db-abeb-360be74fc3f5")) %>%
              addProviderTiles(providers$Stadia.StamenTonerLines,
                options = providerTileOptions(opacity = 0.25, api_key = "2960e34d-9997-48db-abeb-360be74fc3f5")) %>%
              addProviderTiles(providers$Stadia.StamenTonerLabels,
                               options=providerTileOptions(api_key = "2960e34d-9997-48db-abeb-360be74fc3f5")) %>%
      addPolygons(data = airport_noise_contours,
                  fillOpacity = 0.5, 
                  weight = 2, 
                  color = "#808080",
                  fillColor = '#C0C0C0') %>%
      addPolygons(data = airport_noise_data %>% filter(layer == "1_4") %>% head(10000),
                  fillColor = ~pal(DN), 
                  stroke = F)
## Warning in seq.int(0, 1, length.out = n): first element used of 'length.out'
## argument
airport_noise_viz